/*
 * @Author: Seon.Hu SeonHu@126.com
 * @Date: 2023-02-10 13:07:34
 * @LastEditors: Seon.Hu SeonHu@126.com
 * @LastEditTime: 2024-03-24 13:17:23
 * @FilePath: \bg-vben\src\router\routes\modules\iot.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import type { AppRouteModule } from '@/router/types';

import { getParentLayout, LAYOUT } from '@/router/constant';
import { t } from '@/hooks/web/useI18n';

const iot: AppRouteModule = {
  path: '/iot',
  name: 'IoT',
  component: LAYOUT,
  redirect: '/iot/rpclog',
  meta: {
    orderNo: 9000,
    icon: 'eos-icons:iot',
    title: t('iot.route.title'),
    roles: [
      'Root.IoT.Admin.Gateway.Read',
      'Root.IoT.Admin.Gateway.ReadClient',
      'Root.IoT.Admin.ConnectLog.Read',
      'Root.IoT.Admin.Device.ReadGroupTreeNode',
      'Root.IoT.Admin.Device.ReadSimple',
      'Root.IoT.Admin.Device.ReadConfig',
      'Root.IoT.Admin.Device.ReadVariable',
      'Root.IoT.Admin.Driver.ReadSimple',
      'Root.IoT.Admin.RpcLog.Read',
    ],
  },
  children: [
    {
      path: 'driver',
      name: 'DriverPage',
      component: () => import('@/views/iot/driver/index.vue'),
      meta: {
        icon: 'carbon:driver-analysis',
        title: t('iot.route.driver.title'),
        ignoreKeepAlive: false,
        roles: ['Root.IoT.Admin.Driver.ReadSimple'],
      },
    },
    // =============================gateway start=============================
    {
      path: 'gateway',
      name: 'Gateway',
      component: getParentLayout('Gateway'),
      redirect: '/iot/gateway/setting',
      meta: {
        icon: 'carbon:ibm-cloud-transit-gateway',
        title: t('iot.route.gateway.title'),
        roles: [
          'Root.IoT.Admin.Gateway.Read',
          'Root.IoT.Admin.Gateway.ReadClient',
          'Root.IoT.Admin.ConnectLog.Read',
        ],
      },
      children: [
        {
          path: 'setting',
          name: 'GatewaySettingPage',
          component: () => import('@/views/iot/gateway/setting/index.vue'),
          meta: {
            icon: 'clarity:network-settings-line',
            title: t('iot.route.gateway.setting.title'),
            ignoreKeepAlive: false,
            roles: ['Root.IoT.Admin.Gateway.Read'],
          },
        },
        {
          path: 'client',
          name: 'GatewayClientPage',
          component: () => import('@/views/iot/gateway/client/index.vue'),
          meta: {
            icon: 'clarity:thin-client-line',
            title: t('iot.route.gateway.client.title'),
            ignoreKeepAlive: false,
            roles: ['Root.IoT.Admin.Gateway.ReadClient'],
          },
        },
        {
          path: 'connectlog',
          name: 'ConnectLogPage',
          component: () => import('@/views/iot/gateway/connectlog/index.vue'),
          meta: {
            icon: 'mdi:math-log',
            title: t('iot.route.gateway.connectLog.title'),
            ignoreKeepAlive: false,
            roles: ['Root.IoT.Admin.ConnectLog.Read'],
          },
        },
      ],
    },
    // =============================gateway end=============================
    // =============================device start=============================
    {
      path: 'device',
      name: 'Device',
      component: getParentLayout('Device'),
      redirect: '/iot/device/device',
      meta: {
        icon: 'tabler:device-heart-monitor',
        title: t('iot.route.device.title'),
        roles: [
          'Root.IoT.Admin.Device.ReadGroupTreeNode',
          'Root.IoT.Admin.Device.ReadSimple',
          'Root.IoT.Admin.Device.ReadConfig',
          'Root.IoT.Admin.Device.ReadVariable',
        ],
      },
      children: [
        {
          path: 'group',
          name: 'DeviceGroupPage',
          component: () => import('@/views/iot/device/group/index.vue'),
          meta: {
            icon: 'material-symbols:light-group-outline',
            title: t('iot.route.device.group.title'),
            ignoreKeepAlive: false,
            roles: ['Root.IoT.Admin.Device.ReadGroupTreeNode'],
          },
        },
        {
          path: 'device',
          name: 'DevicePage',
          component: () => import('@/views/iot/device/device/index.vue'),
          meta: {
            icon: 'material-symbols:home-iot-device-outline',
            title: t('iot.route.device.title'),
            ignoreKeepAlive: false,
            roles: ['Root.IoT.Admin.Device.ReadSimple'],
          },
        },
        {
          path: 'config',
          name: 'DeviceConfigPage',
          component: () => import('@/views/iot/device/config/index.vue'),
          meta: {
            icon: 'carbon:iot-connect',
            title: t('iot.route.device.config.title'),
            ignoreKeepAlive: false,
            roles: ['Root.IoT.Admin.Device.ReadConfig'],
          },
        },
        {
          path: 'variable',
          name: 'DeviceVariablePage',
          component: () => import('@/views/iot/device/variable/index.vue'),
          meta: {
            icon: 'tabler:device-analytics',
            title: t('iot.route.device.variable.title'),
            ignoreKeepAlive: false,
            roles: ['Root.IoT.Admin.Device.ReadVariable'],
          },
        },
      ],
    },
    // =============================device end=============================
    // =============================state start=============================
    {
      path: 'state',
      name: 'State',
      component: getParentLayout('State'),
      redirect: '/iot/state/device',
      meta: {
        icon: 'mdi:state-machine',
        title: t('iot.route.state.title'),
        roles: ['Root.IoT.Admin.DeviceState.Read', 'Root.IoT.Admin.VariableState.Read'],
      },
      children: [
        {
          path: 'device',
          name: 'DeviceStatePage',
          component: () => import('@/views/iot/state/device/index.vue'),
          meta: {
            icon: 'mdi:sign-real-estate',
            title: t('iot.route.state.device.title'),
            ignoreKeepAlive: false,
            roles: ['Root.IoT.Admin.DeviceState.Read'],
          },
        },
        {
          path: 'variable',
          name: 'VariableStatePage',
          component: () => import('@/views/iot/state/variable/index.vue'),
          meta: {
            icon: 'eos-icons:state',
            title: t('iot.route.state.variable.title'),
            ignoreKeepAlive: false,
            roles: ['Root.IoT.Admin.VariableState.Read'],
          },
        },
      ],
    },
    // =============================state end=============================
    {
      path: 'rpclog',
      name: 'RpcLogPage',
      component: () => import('@/views/iot/rpclog/index.vue'),
      meta: {
        icon: 'mdi:math-log',
        title: t('iot.route.rpcLog.title'),
        ignoreKeepAlive: false,
        roles: ['Root.IoT.Admin.RpcLog.Read'],
      },
    },
  ],
};

export default iot;
